Evaluating Galaxy plots with known simulation data

Recently I have been exploring the idea of visualizing SNP effect sizes to multiple environmental variables. Here, I am extending the results from the I am using the Lotterhos and Whitlock (2015) simulations to explore this concept in a known scenario. Basically, we want to know if the two distinct groups of behavior we observed in the dataset could be generated by chance if there is only one environmental variable driving the adapatation.

I have chosen three replicate datasets from the LW2015 simulations, that were simulated range expansions in a 1 refugia model, with 90 populations sampled and 20 individuals per population. This demography is similar to the range expansion we expect in lodgepole pine, which is the species and dataset I am applying the concept to (Adaptree data). The total sample size is also similar - in the paper I think we have ~600 diploids (1200 chromosomes), whereas here we have 1800 haploid chromosomes.

In LW2015, we simulated adaptation of loci to a single environmental variable (E_main).

Here, I am going to overlay the Adaptree environmental variables. With this data, I am going to essentially repeat the steps that I took for the Adaptree data:

  1. calculate uncorrected Spearman’s rho association between allele frequency (\(f\)) and environment (\(E_i\)).

  2. choose outliers based on uncorrected Spearman’s rho as those that have P-values less than the Bonferroni correction. Hereafter these will be called the “candidate set”.

  3. use Galaxy plots to visualize the candidate set in 2 dimensional space.

I will conduct this exercise for datasets with just neutral loci (9900) and for datasets with neutral loci and loci simulated under varying strengths of selection (9900 and 100).

setwd("Users/katie/Desktop/CurrResearch/1-AdaptreeData/201509_PEGA/simulations/")

Load data

sample_locs <- read.table("data/LW2015samplingdesigns/SchemeRandom1.txt")

dim(sample_locs)
## [1] 90  7
head(sample_locs)
##   PopID X_Pops Y_Pops  R90   R60   R30 NSRangeTrans_30
## 1     1    314    345 TRUE  TRUE  TRUE               0
## 2     2    307    330 TRUE FALSE FALSE               0
## 3     3    195     27 TRUE FALSE FALSE               2
## 4     4     34    357 TRUE FALSE FALSE               0
## 5     5      5     84 TRUE FALSE FALSE               1
## 6     6    328     96 TRUE  TRUE  TRUE               0
## These were created on a 360 x 360 grid
  range(sample_locs$X_Pops)
## [1]   5 351
  range(sample_locs$Y_Pops)
## [1]   4 358
### Adaptree environments
env_AT <- read.csv("../data/MAT06-BLUEs&Climate-pine.csv")
head(env_AT)
##   ProvincialSeedlotsID ExperimentalClimate HtFinalS01_mm HeightFinalS02_mm
## 1        AB_GSIMS_1956               MAT06      35.65049          81.00325
## 2        AB_GSIMS_2186               MAT06      42.29694         107.99599
## 3        AB_GSIMS_2193               MAT06            NA                NA
## 4        AB_GSIMS_2206               MAT06      36.05810         118.99837
## 5        AB_GSIMS_2212               MAT06      32.38957          87.99843
## 6        AB_GSIMS_2235               MAT06      39.36665         116.50214
##   FinalStemDiamS02_mm MaxGthRate_mm_Day FinalShootWeightS02_g
## 1            2.191825          1.519222              1.078899
## 2            3.223240          2.646411              3.806046
## 3                  NA                NA                    NA
## 4            3.158580          2.302429              3.639656
## 5            2.385529          2.274559              1.549045
## 6            2.890474          2.315339              2.162529
##   FinalRootWeightS02_g TotalWeight RootShoot_Ratio   BudSet
## 1            0.3477735    1.430072       0.3021461 168.5562
## 2            1.2560344    5.057673       0.3342296 144.9283
## 3                   NA          NA              NA       NA
## 4            1.8873532    5.524971       0.5244722 144.9671
## 5            0.9172172    2.464662       0.4875097 151.4742
## 6            0.7251025    2.889891       0.3036566 161.0375
##   BudBreakS02_day LinearGthS02_Days Gth5pctS02_Day Gth95pctS02_Day
## 1        45.92458          5.393948       132.2515        174.6045
## 2        47.75024          4.130711       139.4520        175.7595
## 3        49.92475                NA             NA              NA
## 4        45.40084          5.456177       126.4605        179.1811
## 5        49.92462          3.962001       135.6939        169.3393
## 6        46.01196          5.000022       129.4992        176.8384
##   Gth5.95pctS02_Days ColdInjuryFallS02_Mean ColdInjuryMidWinterS02_Mean
## 1           42.40250               76.92681                    72.96522
## 2           37.04660               43.09167                    35.57998
## 3                 NA                     NA                          NA
## 4           54.09819               51.11874                    38.71432
## 5           33.34892               66.96808                    65.57299
## 6           47.25170               51.62439                    46.62356
##   ColdInjurySpringS02_Mean Latitude Longitude Elevation  MAT MWMT  MCMT
## 1                 69.22961    49.67   -110.25      1160  3.4 16.9 -10.4
## 2                 67.20300    54.72   -115.42      1160  1.8 13.8  -9.9
## 3                       NA    53.90   -119.07      1220  2.3 13.5  -8.5
## 4                 67.60140    54.65   -118.83      1021  2.0 14.1 -11.2
## 5                 70.10960    54.42   -119.00      1189  2.1 13.7  -9.6
## 6                 36.07398    55.63   -113.45       914 -0.8 13.9 -19.0
##     TD log.MAP. log.MSP.  AHM  SHM  DD0  DD5 NFFD bFFP eFFP FFP PAS   EMT
## 1 27.3 6.068426 5.549076 31.0 65.9 1179 1405  151  149  248  99 128 -42.5
## 2 23.8 6.504288 6.156979 17.6 29.3 1305 1032  151  146  258 112 163 -41.2
## 3 22.0 6.368187 5.886104 21.1 37.5 1126  982  146  158  252  94 174 -42.0
## 4 25.3 6.408529 5.958425 19.8 36.5 1296 1074  153  148  255 106 174 -43.6
## 5 23.3 6.532334 6.059123 17.6 32.0 1206 1001  153  151  258 107 202 -42.5
## 6 32.9 6.222576 5.826000 18.3 40.9 2055  930  136  160  244  83 149 -46.3
##    EXT Eref CMD
## 1 37.4  660 350
## 2 29.6  462  35
## 3 31.0  497  96
## 4 31.1  490  64
## 5 30.1  463  35
## 6 31.2  470  94
which(names(env_AT)=="Latitude")
## [1] 20
env_AT <- env_AT[complete.cases(env_AT),20:ncol(env_AT)]

plot(env_AT$Longitude, env_AT$Latitude)

### Transform X and Y to match (0 to 360) while preserving
X1 <- range(env_AT$Longitude, na.rm=TRUE)
Y_range <- range(env_AT$Latitude, na.rm=TRUE)

X1 <- env_AT$Longitude - min(env_AT$Longitude, na.rm=TRUE)
Y1 <- env_AT$Latitude - min(env_AT$Latitude, na.rm=TRUE)
plot(X1, Y1)

# multiply both sides by a factor to get the landscape to fit on 360 x 360

X2 <- X1*360/max(X1, na.rm=TRUE) 
Y2 <- Y1*360/max(Y1, na.rm=TRUE) 

plot(X2, Y2)

Interpolate

For each variable, also compare (i) distributions and (ii) autocorrelation between real environments and resampled environment from the 1R model.

env_AT$x <- X2
env_AT$y <- Y2
env_AT2 <- env_AT
coordinates(env_AT) = ~x + y

grd <- expand.grid(x = 1:360, y = 1:360)  # expand points to grid
coordinates(grd) <- ~x + y
gridded(grd) <- TRUE
par(mfrow=c(1,1))
plot(grd, cex = 1.5, col = "grey")
points(env_AT, pch = 1, col = "red", cex = 1)
points(sample_locs$X_Pops, sample_locs$Y_Pops, col="blue", pch="*")

names(env_AT)
##  [1] "Latitude"  "Longitude" "Elevation" "MAT"       "MWMT"     
##  [6] "MCMT"      "TD"        "log.MAP."  "log.MSP."  "AHM"      
## [11] "SHM"       "DD0"       "DD5"       "NFFD"      "bFFP"     
## [16] "eFFP"      "FFP"       "PAS"       "EMT"       "EXT"      
## [21] "Eref"      "CMD"
for (j in 3:22){
  # interpolate!
  thisvarname <- names(env_AT2)[j]
  print(c(j, thisvarname))
  thisdat <- env_AT[,j]
  names(thisdat) = "e"
  head(thisdat)
  idw <- idw(formula = e ~ 1, locations = thisdat, newdata = grd)  

  idw.output = as.data.frame(idw)  # output is defined as a data table

  names(idw.output)[1:3] <- c("long", "lat", "e.pred")  # give names to the modelled variables

  head(idw.output)
  ggplot() + geom_tile(data = idw.output, aes(x = long, y = lat, fill = e.pred)) + geom_point(data = env_AT2, aes(x = X2, y = Y2), shape = 21, 
        colour = "red") + geom_point(data = sample_locs, aes(x = X_Pops, y = Y_Pops), shape = 25,
        colour = "yellow")

  #head(sample_locs)

  for (i in 1:nrow(sample_locs)){
    wrow <- which(idw.output$long==sample_locs$X_Pops[i] & idw.output$lat==sample_locs$Y_Pops[i])
    sample_locs$e[i] <- idw.output$e.pred[wrow]
  }
  head(sample_locs)
  names(sample_locs)[ncol(sample_locs)] <- thisvarname

  par(mfrow=c(2,1), mar=c(2,4,2,0))
  b<-hist(env_AT2[,j], main=paste("Real", thisvarname))
  hist(sample_locs[,ncol(sample_locs)], breaks=b$breaks, main="Interpolated")


  ncf.cor.real <- correlog(env_AT2$x, env_AT2$y, env_AT2[,j],  increment=2, resamp=500, quiet = TRUE)

  ncf.cor.sample <- correlog(sample_locs$X_Pops, sample_locs$Y_Pops, sample_locs[,ncol(sample_locs)],  increment=2, resamp=500, quiet = TRUE)

  par(mfrow=c(2,1), mar=c(2,4,2,0))
  plot(ncf.cor.real$correlation, ylim= c(-2,2), main=paste("True",thisvarname), type="l")
  plot(ncf.cor.sample$correlation, ylim= c(-2,2), main="Interpolated", type="l")

}
## [1] "3"         "Elevation"
## [inverse distance weighted interpolation]

## [1] "4"   "MAT"
## [inverse distance weighted interpolation]

## [1] "5"    "MWMT"
## [inverse distance weighted interpolation]

## [1] "6"    "MCMT"
## [inverse distance weighted interpolation]

## [1] "7"  "TD"
## [inverse distance weighted interpolation]

## [1] "8"        "log.MAP."
## [inverse distance weighted interpolation]

## [1] "9"        "log.MSP."
## [inverse distance weighted interpolation]

## [1] "10"  "AHM"
## [inverse distance weighted interpolation]

## [1] "11"  "SHM"
## [inverse distance weighted interpolation]

## [1] "12"  "DD0"
## [inverse distance weighted interpolation]

## [1] "13"  "DD5"
## [inverse distance weighted interpolation]

## [1] "14"   "NFFD"
## [inverse distance weighted interpolation]

## [1] "15"   "bFFP"
## [inverse distance weighted interpolation]

## [1] "16"   "eFFP"
## [inverse distance weighted interpolation]

## [1] "17"  "FFP"
## [inverse distance weighted interpolation]

## [1] "18"  "PAS"
## [inverse distance weighted interpolation]

## [1] "19"  "EMT"
## [inverse distance weighted interpolation]

## [1] "20"  "EXT"
## [inverse distance weighted interpolation]

## [1] "21"   "Eref"
## [inverse distance weighted interpolation]

## [1] "22"  "CMD"
## [inverse distance weighted interpolation]

Compare correlation matrices of raw and interpolated environments

Compare correlation structure between real environments and resampled environment from the 1R model.

head(env_AT2)
##   Latitude Longitude Elevation  MAT MWMT  MCMT   TD log.MAP. log.MSP.  AHM
## 1    49.67   -110.25      1160  3.4 16.9 -10.4 27.3 6.068426 5.549076 31.0
## 2    54.72   -115.42      1160  1.8 13.8  -9.9 23.8 6.504288 6.156979 17.6
## 4    54.65   -118.83      1021  2.0 14.1 -11.2 25.3 6.408529 5.958425 19.8
## 5    54.42   -119.00      1189  2.1 13.7  -9.6 23.3 6.532334 6.059123 17.6
## 6    55.63   -113.45       914 -0.8 13.9 -19.0 32.9 6.222576 5.826000 18.3
## 7    59.70   -117.98       731 -3.9 14.0 -24.4 38.4 6.003887 5.480639 15.0
##    SHM  DD0  DD5 NFFD bFFP eFFP FFP PAS   EMT  EXT Eref CMD        x
## 1 65.9 1179 1405  151  149  248  99 128 -42.5 37.4  660 350 358.6867
## 2 29.3 1305 1032  151  146  258 112 163 -41.2 29.6  462  35 273.8167
## 4 36.5 1296 1074  153  148  255 106 174 -43.6 31.1  490  64 217.8386
## 5 32.0 1206 1001  153  151  258 107 202 -42.5 30.1  463  35 215.0479
## 6 40.9 2055  930  136  160  244  83 149 -46.3 31.2  470  94 306.1560
## 7 58.3 3031  843  123  156  239  82 168 -49.3 32.2  384 144 231.7921
##           y
## 1  20.82645
## 2 187.76860
## 4 185.45455
## 5 177.85124
## 6 217.85124
## 7 352.39669
(creal <- cor(env_AT2[,1:22]))
##              Latitude   Longitude   Elevation         MAT        MWMT
## Latitude   1.00000000 -0.34593875 -0.53016376 -0.54886123 -0.04849022
## Longitude -0.34593875  1.00000000  0.42872283 -0.14759206  0.20578507
## Elevation -0.53016376  0.42872283  1.00000000 -0.33268858 -0.63674973
## MAT       -0.54886123 -0.14759206 -0.33268858  1.00000000  0.57909805
## MWMT      -0.04849022  0.20578507 -0.63674973  0.57909805  1.00000000
## MCMT      -0.69766323 -0.24399906  0.06882824  0.84960653  0.10215145
## TD         0.65461824  0.31365271 -0.30834498 -0.59964860  0.28140359
## log.MAP.  -0.29487631 -0.09505132  0.17046127  0.22994038 -0.21385952
## log.MSP.   0.15519310  0.34130874  0.19976655 -0.22916110 -0.22278969
## AHM       -0.07333708  0.02035374 -0.27871371  0.31325250  0.47826670
## SHM       -0.19142689 -0.18696160 -0.35397959  0.41282772  0.53146188
## DD0        0.68749271  0.21986874  0.03472285 -0.92036724 -0.23606663
## DD5       -0.13195970  0.07445573 -0.67528833  0.75228521  0.95854093
## NFFD      -0.11255267 -0.18990280 -0.62917655  0.77878308  0.67477746
## bFFP      -0.15060059 -0.07118125  0.67799164 -0.50064911 -0.76795501
## eFFP      -0.14330071 -0.22576324 -0.51709661  0.74725518  0.54292792
## FFP        0.01593969 -0.06588542 -0.63705718  0.64794854  0.70338667
## PAS       -0.32617106 -0.09301837  0.42135593 -0.07007206 -0.40359400
## EMT       -0.49983394 -0.33700331 -0.23772478  0.83158935  0.30670129
## EXT       -0.33139430  0.14801221 -0.43406237  0.62661226  0.85041382
## Eref      -0.53112833  0.16972381 -0.29877992  0.78499959  0.75647150
## CMD       -0.31274782 -0.18044142 -0.30331352  0.50028497  0.51627501
##                  MCMT          TD    log.MAP.     log.MSP.          AHM
## Latitude  -0.69766323  0.65461824 -0.29487631  0.155193099 -0.073337080
## Longitude -0.24399906  0.31365271 -0.09505132  0.341308737  0.020353741
## Elevation  0.06882824 -0.30834498  0.17046127  0.199766552 -0.278713715
## MAT        0.84960653 -0.59964860  0.22994038 -0.229161096  0.313252500
## MWMT       0.10215145  0.28140359 -0.21385952 -0.222789686  0.478266702
## MCMT       1.00000000 -0.92574395  0.45266071 -0.136402077  0.046828661
## TD        -0.92574395  1.00000000 -0.51742435  0.047428830  0.136156987
## log.MAP.   0.45266071 -0.51742435  1.00000000  0.510182726 -0.824746879
## log.MSP.  -0.13640208  0.04742883  0.51018273  1.000000000 -0.639300317
## AHM        0.04682866  0.13615699 -0.82474688 -0.639300317  1.000000000
## SHM        0.17925937  0.02877209 -0.50797851 -0.925876764  0.738338590
## DD0       -0.97351273  0.84955191 -0.36052506  0.186371072 -0.167812089
## DD5        0.31353975  0.06175519 -0.09869558 -0.216102097  0.462967338
## NFFD       0.52946082 -0.25406727  0.27236537 -0.066537066  0.111971441
## bFFP      -0.13822530 -0.15887049 -0.07891956 -0.100986047 -0.128993433
## eFFP       0.58574828 -0.35836993  0.38458259  0.004739958 -0.011164211
## FFP        0.36188239 -0.08140803  0.23065962  0.060719830  0.069131842
## PAS        0.22982253 -0.37482895  0.77123395  0.178860381 -0.699455233
## EMT        0.84101276 -0.69464061  0.44866516 -0.263356589  0.008946374
## EXT        0.23525655  0.09591923 -0.26177716 -0.479399400  0.594765776
## Eref       0.47491366 -0.17089848 -0.15600667 -0.395836574  0.580334457
## CMD        0.28473357 -0.07912667 -0.45788108 -0.897456436  0.747462538
##                   SHM         DD0         DD5        NFFD        bFFP
## Latitude  -0.19142689  0.68749271 -0.13195970 -0.11255267 -0.15060059
## Longitude -0.18696160  0.21986874  0.07445573 -0.18990280 -0.07118125
## Elevation -0.35397959  0.03472285 -0.67528833 -0.62917655  0.67799164
## MAT        0.41282772 -0.92036724  0.75228521  0.77878308 -0.50064911
## MWMT       0.53146188 -0.23606663  0.95854093  0.67477746 -0.76795501
## MCMT       0.17925937 -0.97351273  0.31353975  0.52946082 -0.13822530
## TD         0.02877209  0.84955191  0.06175519 -0.25406727 -0.15887049
## log.MAP.  -0.50797851 -0.36052506 -0.09869558  0.27236537 -0.07891956
## log.MSP.  -0.92587676  0.18637107 -0.21610210 -0.06653707 -0.10098605
## AHM        0.73833859 -0.16781209  0.46296734  0.11197144 -0.12899343
## SHM        1.00000000 -0.26474058  0.51748641  0.29038164 -0.18155844
## DD0       -0.26474058  1.00000000 -0.43891355 -0.56229672  0.19164850
## DD5        0.51748641 -0.43891355  1.00000000  0.81088430 -0.81168803
## NFFD       0.29038164 -0.56229672  0.81088430  1.00000000 -0.86079275
## bFFP      -0.18155844  0.19164850 -0.81168803 -0.86079275  1.00000000
## eFFP       0.19169258 -0.59163639  0.69065279  0.96024719 -0.79005499
## FFP        0.19673995 -0.39537130  0.79959927  0.95726079 -0.95514574
## PAS       -0.28438626 -0.14125809 -0.38813131 -0.17160899  0.33707626
## EMT        0.33603370 -0.82214267  0.49797544  0.77575626 -0.41317377
## EXT        0.69989022 -0.37418189  0.83579686  0.48520037 -0.44513086
## Eref       0.61131248 -0.61197794  0.80369907  0.48719341 -0.36473543
## CMD        0.95514023 -0.38364911  0.52539226  0.25447843 -0.10186767
##                   eFFP         FFP         PAS          EMT         EXT
## Latitude  -0.143300713  0.01593969 -0.32617106 -0.499833941 -0.33139430
## Longitude -0.225763237 -0.06588542 -0.09301837 -0.337003311  0.14801221
## Elevation -0.517096611 -0.63705718  0.42135593 -0.237724780 -0.43406237
## MAT        0.747255184  0.64794854 -0.07007206  0.831589349  0.62661226
## MWMT       0.542927924  0.70338667 -0.40359400  0.306701285  0.85041382
## MCMT       0.585748285  0.36188239  0.22982253  0.841012760  0.23525655
## TD        -0.358369926 -0.08140803 -0.37482895 -0.694640609  0.09591923
## log.MAP.   0.384582588  0.23065962  0.77123395  0.448665165 -0.26177716
## log.MSP.   0.004739958  0.06071983  0.17886038 -0.263356589 -0.47939940
## AHM       -0.011164211  0.06913184 -0.69945523  0.008946374  0.59476578
## SHM        0.191692577  0.19673995 -0.28438626  0.336033703  0.69989022
## DD0       -0.591636385 -0.39537130 -0.14125809 -0.822142670 -0.37418189
## DD5        0.690652789  0.79959927 -0.38813131  0.497975436  0.83579686
## NFFD       0.960247187  0.95726079 -0.17160899  0.775756255  0.48520037
## bFFP      -0.790054985 -0.95514574  0.33707626 -0.413173766 -0.44513086
## eFFP       1.000000000  0.93562187 -0.05868766  0.793084423  0.32767693
## FFP        0.935621874  1.00000000 -0.22224297  0.619756924  0.41452280
## PAS       -0.058687657 -0.22224297  1.00000000  0.178639013 -0.27313623
## EMT        0.793084423  0.61975692  0.17863901  1.000000000  0.38425540
## EXT        0.327676930  0.41452280 -0.27313623  0.384255398  1.00000000
## Eref       0.364042121  0.38586534 -0.25324651  0.475779573  0.90781093
## CMD        0.143692889  0.12806288 -0.23538095  0.376720621  0.76621296
##                 Eref         CMD
## Latitude  -0.5311283 -0.31274782
## Longitude  0.1697238 -0.18044142
## Elevation -0.2987799 -0.30331352
## MAT        0.7849996  0.50028497
## MWMT       0.7564715  0.51627501
## MCMT       0.4749137  0.28473357
## TD        -0.1708985 -0.07912667
## log.MAP.  -0.1560067 -0.45788108
## log.MSP.  -0.3958366 -0.89745644
## AHM        0.5803345  0.74746254
## SHM        0.6113125  0.95514023
## DD0       -0.6119779 -0.38364911
## DD5        0.8036991  0.52539226
## NFFD       0.4871934  0.25447843
## bFFP      -0.3647354 -0.10186767
## eFFP       0.3640421  0.14369289
## FFP        0.3858653  0.12806288
## PAS       -0.2532465 -0.23538095
## EMT        0.4757796  0.37672062
## EXT        0.9078109  0.76621296
## Eref       1.0000000  0.71947132
## CMD        0.7194713  1.00000000
head(sample_locs)
##   PopID X_Pops Y_Pops  R90   R60   R30 NSRangeTrans_30 Elevation
## 1     1    314    345 TRUE  TRUE  TRUE               0  980.5921
## 2     2    307    330 TRUE FALSE FALSE               0  961.8469
## 3     3    195     27 TRUE FALSE FALSE               2 1346.5580
## 4     4     34    357 TRUE FALSE FALSE               0  922.4852
## 5     5      5     84 TRUE FALSE FALSE               1 1028.5271
## 6     6    328     96 TRUE  TRUE  TRUE               0 1294.2153
##          MAT     MWMT       MCMT       TD log.MAP. log.MSP.      AHM
## 1  0.6724280 14.14300 -14.558235 28.69819 6.329870 5.732783 19.08832
## 2  0.4016679 14.17844 -15.301201 29.47558 6.309771 5.726908 18.90590
## 3  3.1140827 13.86779  -7.351793 21.22018 6.426370 5.416452 21.74771
## 4 -0.3975880 13.62096 -15.872037 29.49228 6.282420 5.586239 17.76339
## 5  2.5903738 13.73352  -9.277635 23.01224 6.502223 5.663558 19.69240
## 6  1.9986234 13.84836 -10.706235 24.55241 6.466997 5.837874 19.35669
##        SHM       DD0      DD5     NFFD     bFFP     eFFP      FFP      PAS
## 1 47.25382 1684.5939 1014.651 142.3535 155.5138 248.2102 92.75406 212.6854
## 2 47.55405 1770.2248 1010.685 141.5871 155.1883 247.6836 92.59247 207.1350
## 3 63.04856  915.1264 1035.331 153.3500 157.8748 254.8701 97.01454 293.8494
## 4 51.93678 1912.6554  907.267 134.0457 163.3684 246.1616 82.78209 235.9674
## 5 49.46319 1096.5114 1035.222 152.4599 157.9691 253.4832 95.50726 264.8630
## 6 42.33687 1240.6958 1011.372 141.4806 159.8366 248.7352 88.93582 247.4103
##         EMT      EXT     Eref      CMD
## 1 -43.96263 32.25818 491.0270 142.8683
## 2 -44.23797 32.29835 485.9397 141.7057
## 3 -37.44551 32.94855 544.4767 251.6011
## 4 -46.74088 31.59091 440.1183 155.5851
## 5 -39.75605 32.27811 521.2485 178.3484
## 6 -42.78018 32.31376 527.7532 132.4428
names(sample_locs)
##  [1] "PopID"           "X_Pops"          "Y_Pops"         
##  [4] "R90"             "R60"             "R30"            
##  [7] "NSRangeTrans_30" "Elevation"       "MAT"            
## [10] "MWMT"            "MCMT"            "TD"             
## [13] "log.MAP."        "log.MSP."        "AHM"            
## [16] "SHM"             "DD0"             "DD5"            
## [19] "NFFD"            "bFFP"            "eFFP"           
## [22] "FFP"             "PAS"             "EMT"            
## [25] "EXT"             "Eref"            "CMD"
(csim <- cor(sample_locs[,c(2:3,8:27)]))
##                X_Pops       Y_Pops    Elevation         MAT        MWMT
## X_Pops     1.00000000 -0.015558769  0.438960656 -0.26357597  0.28867477
## Y_Pops    -0.01555877  1.000000000 -0.538772244 -0.78111063  0.08803844
## Elevation  0.43896066 -0.538772244  1.000000000  0.03573318 -0.41924233
## MAT       -0.26357597 -0.781110627  0.035733180  1.00000000  0.12540371
## MWMT       0.28867477  0.088038441 -0.419242330  0.12540371  1.00000000
## MCMT      -0.32891586 -0.811880431  0.175013840  0.96580628 -0.10515383
## TD         0.36879660  0.800056974 -0.245288142 -0.90970921  0.28099766
## log.MAP.  -0.18091423 -0.538248476  0.103620419  0.67738915 -0.10469407
## log.MSP.   0.47065755  0.054632649  0.265865272 -0.19444674 -0.05687606
## AHM        0.06032185 -0.004452211 -0.046116930 -0.03780797  0.26104946
## SHM       -0.32050533 -0.118998500 -0.268798950  0.26855088  0.30798433
## DD0        0.29956748  0.828152513 -0.190590480 -0.96983541  0.09297180
## DD5        0.03552172 -0.294022773 -0.414056200  0.62630168  0.82449644
## NFFD      -0.29871263 -0.362341974 -0.435812889  0.77611911  0.38131361
## bFFP      -0.08426812 -0.132805544  0.596459739 -0.21142883 -0.71056170
## eFFP      -0.35062299 -0.396537007 -0.387380093  0.80716621  0.28821957
## FFP       -0.16149560 -0.167926111 -0.537806368  0.58901515  0.54164866
## PAS       -0.15339431 -0.465413498  0.428384654  0.33413601 -0.39376957
## EMT       -0.36858006 -0.645468247 -0.102568132  0.92727980  0.06598269
## EXT        0.17222035 -0.457383620  0.008278644  0.50943316  0.67148818
## Eref       0.10608545 -0.787944368  0.215222392  0.83001907  0.40618559
## CMD       -0.32581303 -0.345085704 -0.109781480  0.45814292  0.20765096
##                  MCMT         TD    log.MAP.    log.MSP.          AHM
## X_Pops    -0.32891586  0.3687966 -0.18091423  0.47065755  0.060321849
## Y_Pops    -0.81188043  0.8000570 -0.53824848  0.05463265 -0.004452211
## Elevation  0.17501384 -0.2452881  0.10362042  0.26586527 -0.046116930
## MAT        0.96580628 -0.9097092  0.67738915 -0.19444674 -0.037807973
## MWMT      -0.10515383  0.2809977 -0.10469407 -0.05687606  0.261049458
## MCMT       1.00000000 -0.9839182  0.73250666 -0.16587391 -0.135337451
## TD        -0.98391822  1.0000000 -0.72384645  0.15107673  0.174921575
## log.MAP.   0.73250666 -0.7238465  1.00000000  0.28699855 -0.737781189
## log.MSP.  -0.16587391  0.1510767  0.28699855  1.00000000 -0.572404307
## AHM       -0.13533745  0.1749216 -0.73778119 -0.57240431  1.000000000
## SHM        0.18638425 -0.1260562 -0.27277290 -0.95209667  0.643036883
## DD0       -0.99066003  0.9731124 -0.67386256  0.19210516  0.055645007
## DD5        0.42192921 -0.2590127  0.31046256 -0.11145083  0.126449458
## NFFD       0.67836288 -0.5849142  0.66414840 -0.08511383 -0.243502014
## bFFP      -0.02255193 -0.1065759 -0.13933848 -0.18001228  0.054558804
## eFFP       0.73375992 -0.6550179  0.71796301 -0.07103251 -0.293390967
## FFP        0.44727504 -0.3331761  0.50115103  0.05239098 -0.204750478
## PAS        0.47549813 -0.5294172  0.67025840  0.03975171 -0.523965673
## EMT        0.91030161 -0.8660199  0.75095624 -0.27257679 -0.203190434
## EXT        0.35685715 -0.2248011  0.09526491 -0.44093561  0.381354361
## Eref       0.73634243 -0.6386866  0.39853060 -0.24319375  0.233505843
## CMD        0.39972595 -0.3501465 -0.11304602 -0.91728876  0.599817123
##                    SHM          DD0         DD5        NFFD         bFFP
## X_Pops    -0.320505326  0.299567477  0.03552172 -0.29871263 -0.084268122
## Y_Pops    -0.118998500  0.828152513 -0.29402277 -0.36234197 -0.132805544
## Elevation -0.268798950 -0.190590480 -0.41405620 -0.43581289  0.596459739
## MAT        0.268550879 -0.969835413  0.62630168  0.77611911 -0.211428831
## MWMT       0.307984326  0.092971800  0.82449644  0.38131361 -0.710561698
## MCMT       0.186384254 -0.990660031  0.42192921  0.67836288 -0.022551927
## TD        -0.126056188  0.973112366 -0.25901268 -0.58491424 -0.106575884
## log.MAP.  -0.272772897 -0.673862564  0.31046256  0.66414840 -0.139338478
## log.MSP.  -0.952096668  0.192105164 -0.11145083 -0.08511383 -0.180012284
## AHM        0.643036883  0.055645007  0.12644946 -0.24350201  0.054558804
## SHM        1.000000000 -0.217584070  0.33328744  0.17894013  0.007288909
## DD0       -0.217584070  1.000000000 -0.42265606 -0.63347536 -0.006278299
## DD5        0.333287437 -0.422656062  1.00000000  0.79903419 -0.774940756
## NFFD       0.178940132 -0.633475361  0.79903419  1.00000000 -0.684155294
## bFFP       0.007288909 -0.006278299 -0.77494076 -0.68415529  1.000000000
## eFFP       0.147273367 -0.689376045  0.73727254  0.98745841 -0.613595699
## FFP        0.083077049 -0.405709567  0.84098543  0.94189321 -0.882780158
## PAS       -0.080859736 -0.447768559 -0.18336670  0.08027485  0.409712860
## EMT        0.307068033 -0.882591876  0.57962225  0.86174912 -0.260425705
## EXT        0.640888072 -0.388970751  0.71907574  0.37738625 -0.233315339
## Eref       0.409043891 -0.770087322  0.68926256  0.52028586 -0.137760868
## CMD        0.954213720 -0.441087347  0.33680382  0.21990780  0.121302865
##                  eFFP         FFP         PAS         EMT          EXT
## X_Pops    -0.35062299 -0.16149560 -0.15339431 -0.36858006  0.172220355
## Y_Pops    -0.39653701 -0.16792611 -0.46541350 -0.64546825 -0.457383620
## Elevation -0.38738009 -0.53780637  0.42838465 -0.10256813  0.008278644
## MAT        0.80716621  0.58901515  0.33413601  0.92727980  0.509433156
## MWMT       0.28821957  0.54164866 -0.39376957  0.06598269  0.671488180
## MCMT       0.73375992  0.44727504  0.47549813  0.91030161  0.356857154
## TD        -0.65501793 -0.33317607 -0.52941718 -0.86601989 -0.224801092
## log.MAP.   0.71796301  0.50115103  0.67025840  0.75095624  0.095264908
## log.MSP.  -0.07103251  0.05239098  0.03975171 -0.27257679 -0.440935608
## AHM       -0.29339097 -0.20475048 -0.52396567 -0.20319043  0.381354361
## SHM        0.14727337  0.08307705 -0.08085974  0.30706803  0.640888072
## DD0       -0.68937605 -0.40570957 -0.44776856 -0.88259188 -0.388970751
## DD5        0.73727254  0.84098543 -0.18336670  0.57962225  0.719075739
## NFFD       0.98745841  0.94189321  0.08027485  0.86174912  0.377386253
## bFFP      -0.61359570 -0.88278016  0.40971286 -0.26042570 -0.233315339
## eFFP       1.00000000  0.91251633  0.14813894  0.89010557  0.315043422
## FFP        0.91251633  1.00000000 -0.12326247  0.66435533  0.310530230
## PAS        0.14813894 -0.12326247  1.00000000  0.38027013  0.043278897
## EMT        0.89010557  0.66435533  0.38027013  1.00000000  0.440803909
## EXT        0.31504342  0.31053023  0.04327890  0.44080391  1.000000000
## Eref       0.50698662  0.37431940  0.18860230  0.68393012  0.835292128
## CMD        0.20571086  0.05854206  0.08253313  0.44709389  0.694466879
##                 Eref         CMD
## X_Pops     0.1060854 -0.32581303
## Y_Pops    -0.7879444 -0.34508570
## Elevation  0.2152224 -0.10978148
## MAT        0.8300191  0.45814292
## MWMT       0.4061856  0.20765096
## MCMT       0.7363424  0.39972595
## TD        -0.6386866 -0.35014646
## log.MAP.   0.3985306 -0.11304602
## log.MSP.  -0.2431937 -0.91728876
## AHM        0.2335058  0.59981712
## SHM        0.4090439  0.95421372
## DD0       -0.7700873 -0.44108735
## DD5        0.6892626  0.33680382
## NFFD       0.5202859  0.21990780
## bFFP      -0.1377609  0.12130286
## eFFP       0.5069866  0.20571086
## FFP        0.3743194  0.05854206
## PAS        0.1886023  0.08253313
## EMT        0.6839301  0.44709389
## EXT        0.8352921  0.69446688
## Eref       1.0000000  0.57743225
## CMD        0.5774322  1.00000000
plot(creal, csim)
abline(0,1)

par(mfrow=c(2,1))
col <- two.colors(start="red", end="blue", middle="grey")
image.plot(creal, col=col)
image.plot(csim, col=col)

Write simulated environments to file

write.table(sample_locs, "data/results_AdaptreeEnviFor_R90.txt")